﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Sl.Support.McuBytes {
	internal static class  Ushort_Expand {
		/// <summary>获取低8位。</summary>
		internal static byte ByteLow(this ushort u16) {
			return (byte)(u16);
		}
		/// <summary>获取高8位。</summary>
		internal static byte ByteHigh(this ushort u16) {
			return (byte)(u16 >> 8);
		}
		/// <summary>从两个byte转换为uint16</summary>
		internal static UInt16 ToUint16(byte low, byte high) {
			UInt16 rev = 0;
			rev += high;
			rev <<= 8;
			rev += low;
			return rev;
		}
		/// <summary>从一个比特数组中特定位置提取出一个uint16，小端模式。建议使用流来完成更复杂的操作。</summary>
		internal static ushort GetUint16(this byte[] b, int num) {
			return (ushort)((int)b[num] + (((int)b[num + 1]) << 8));
		}
	}
}
